//
//  MGEmpty.m
//  MGPublic
//
//  Created by lhongl on 2025/10/30.
//

#import "MGEmpty.h"

@implementation MGEmpty
/// 判断字符串是否为空
+ (BOOL (^)(NSString *string))isEmpty {
    return ^(NSString *string){
        if (!string || string == nil || string == NULL){
            return YES;
        }
        if ([string isKindOfClass:[NSNull class]]) {
            return  YES;
        }
        if (![string isKindOfClass:[NSString class]]) {
            return YES;
        }
        if (string.length == 0) {
            return YES;
        }
        if ([[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length]==0){
            return YES;
        }
        return NO;
    };
}

/// 判断数组是否为空
+ (BOOL (^)(NSArray *array))isEmptyArray {
    return ^(NSArray *array){
        if (!array || array == nil || array == NULL) {
            return YES;
        }
        if ([array isKindOfClass:[NSNull class]]) {
            return  YES;
        }
        if(![array isKindOfClass:[NSArray class]]) {
            return YES;
        }
        if(array.count == 0){
            return YES;
        }
        return NO;
    };
}

/// 判断字典是否为空
+ (BOOL (^)(NSDictionary *dic))isEmptyDiction {
    return ^(NSDictionary *dic){
        if (!dic || dic == nil || dic == NULL) {
            return YES;
        }
        if ([dic isKindOfClass:[NSNull class]]) {
            return  YES;
        }
        if(![dic isKindOfClass:[NSDictionary class]]) {
            return YES;
        }
        if (dic.count == 0) {
            return YES;
        }
        return NO;
    };
}

@end
